00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00052 define("PATH_TO_ROOT", "../");
00053
00054 require_once (PATH_TO_ROOT."forum/classes/distribution/class.distributor.inc.php");
00055 require_once (PATH_TO_ROOT."forum/classes/distribution/class.subscribersdistributionhandler.inc.php");
00056 require_once (PATH_TO_ROOT."forum/classes/distribution/class.mustseedistributionhandler.inc.php");
00058 require_once (PATH_TO_ROOT."common/tinymceconfig.inc.php");
00059
00061 require_once (PATH_TO_ROOT."common/init.inc.php");
00063 require_once (PATH_TO_ROOT."common/classes/class.email.inc.php");
00064 if (isset($_POST['Cancel'])) {
00065 header("Location: ".$_SERVER['PHP_SELF']);
00066 exit;
00067 }
00069 require_once (PATH_TO_ROOT."common/header.inc.php");
00070 include_once "header.inc.php";
00071 $eStudyPage->appendJavaScriptFile($js);
00072 writeContentHeader("Forum");
00073 include_once "./classes/class.header.inc.php";
00074
00075 $post['posttext'] = ((isset($_POST['post']['posttext'])) ? $_POST['post']['posttext'] : '');
00076 if ($g_user['userID'] == 0 && !$P->has_permission(P_REPLY)) {
00077 $navpath.= "Neue Antwort";
00078 errormessage('Fehler', 'Sie müssen registriert sein, um Beiträge erstellen zu können');
00079 }
00080 requires_permission(P_REPLY);
00081 if (isset($_SESSION["roleID"])) {
00082 $role = new Role($_SESSION["roleID"]);
00083 } else $role = null;
00084 if (isset($_SESSION["teamID"])) {
00085 $team = new Team($_SESSION["teamID"]);
00086 } else $team = null;
00087 $msg = '';
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 if ($g_user['userID'] == 0 && $P->has_permission(P_REPLY)) {
00098
00099
00100 }
00101 $testlen = strlen(preg_replace("/(\s+|( )+)/", '', ($post['postcode'] ? $mainBBCode->stripTags($post['posttext']) : $post['posttext'])));
00102 if ($testlen < $config['message_minlength']) {
00103 $msg.= "Der Text ist zu kurz<br/>";
00104 }
00105 if ($testlen > $config['message_maxlength']) {
00106 $msg.= "Der Text ist zu lang<br/>";
00107 }
00108
00109 if (isset($post['preview'])) {
00110 $bbcode = new BBCode(true, $config["imageslevel"] != 2, (bool)$post["postsmilies"], (bool)$post["postcode"], true);
00111 $post['pretext'] = $bbcode->parse($post['posttext']);
00112 if (isset($g_user['userhidesig']) && $g_user['userhidesig'] != 1 && !empty($g_user['usersignature']) && !isset($role)) {
00113 $post['pretext'].= "<br/>-- <br/>".$mainBBCode->parse($g_user['usersignature']);
00114 }
00115 $replytext = Data::toHTML($post['posttext'], false);
00116 $Tpostings = new Template("templates/replypreview.html");
00117 $Tframe = new Template("templates/frame.html");
00118 $Tpostingrow = new Template("templates/preview.html");
00119 if (isset($_POST['cx1'])) {
00120 $picData = $db->get_row("SELECT postfilename, postfilesavename FROM forum_post WHERE threadid=".$thread['threadid']." ORDER BY posttime LIMIT 1");
00121 if ($picData) {
00122 $ext = "&ext=".strrchr($picData->postfilename, ".");
00123 $picPath = PATH_TO_ROOT.$settings["upload_path"].'forum/course/'.$_SESSION['course'].'/board/'.$board['boardid'].'/'.$picData->postfilesavename;
00124 $cropParam = "&cx1=".$_POST['cx1']."&cy1=".$_POST['cy1']."&cx2=".$_POST['cx2']."&cy2=".$_POST['cy2'];
00125 $picquotepreview = ' <img src="'.PATH_TO_ROOT.'common/makethumb.php?picurl='.rawurlencode($picPath) .$ext.$cropParam.'" alt="Bildzitat Ansicht" style="border: 1px solid #000000;" />';
00126 $picquotedata = '
00127 <p class="pForm">
00128 <input type="hidden" name="picquote" value="1" />
00129 <input type="hidden" name="cx1" value="'.$_POST['cx1'].'" />
00130 <input type="hidden" name="cy1" value="'.$_POST['cy1'].'" />
00131 <input type="hidden" name="cx2" value="'.$_POST['cx2'].'" />
00132 <input type="hidden" name="cy2" value="'.$_POST['cy2'].'" />
00133 </p>
00134 ';
00135 $post['pretext'] = '<div style="text-align: center; width: 100%;">'.$picquotepreview.'<br /><br /></div>'.$post['pretext'];
00136 }
00137 } else {
00138 $picquotedata = '';
00139 }
00140 $time = Output::echoDate("d.m.Y, H:i");
00141 $roleInfoText = "";
00142 if ($g_user['userID']) {
00143 $replyusername = Data::toHTML($g_user['username'], false);
00144 $post['avatar'] = '';
00145 if (isset($role)) {
00146 $replyusername.= " (".Data::toHTML($role->getName($_SESSION["gender"]), false) .")";
00147 $avatarURL = $role->getAvatarURL($g_user["userID"]);
00148 if (!empty($avatarURL)) {
00149 $post["avatar"] = "<img src='$avatarURL' alt='Avatar von $replyusername' />";
00150 }
00151 $roleInfoText = "<tr><td colspan='2' class='message'>Sie nehmen zur Zeit die Rolle <strong>".Data::toHTML($role->getName($_SESSION["gender"]), false) ."</strong> ein.<br />Wenn Sie einen Beitrag im Forum verfassen, wird dieser unter Ihrem Rollennamen und mit Ihrem Rollenavatar veröffentlicht.</td></tr>";
00152 }
00153 if (isset($team)) {
00154 $replyusername.= " (".$team->getName() .")";
00155 }
00156 } else {
00157 if ($config['guestmode']) {
00158 $replyusername = Data::toHTML($post['postguestname'], false) ."<p class='pForm'><input type=\"hidden\" name=\"post[postguestname]\" value=\"".Data::toHTML($post['postguestname'], false) ."\"/></p>";
00159 } else {
00160 $replyusername = '';
00161 }
00162 }
00163 if ($post['postcode']) {
00164 $codechecked = ' checked="checked"';
00165 } else {
00166 $codechecked = '';
00167 }
00168 if ($post['postsmilies']) {
00169 $smilieschecked = ' checked="checked"';
00170 } else {
00171 $smilieschecked = '';
00172 }
00173 if ($config['smilies']) {
00174 $smilies_on_off = "AN";
00175 $smilietext = "<tr class='tableCell'> <td>Smilies</td> <td> <p class='pForm'><input type='checkbox' id='smilies' name='post[postsmilies]' value='1' $smilieschecked /></p>
00176 <label for='smilies'>Smilies wie :), ;) usw. als Grafiken darstellen?</label></td></tr>";
00177 } else {
00178 $smilies_on_off = "AUS";
00179 $smilietext = "";
00180 }
00181 if ($config['use_email']) {
00182 $notifyavailable = '';
00183 } else {
00184 $notifyavailable = ' (Derzeit nicht verfügbar)';
00185 }
00186 $navpath.= 'Antwort Vorschau';
00187
00188
00189
00190 $SQL = "SELECT threadrate, userID FROM forum_thread WHERE threadid = '$thread[threadid]'";
00191 $res = $db->get_row($SQL);
00192
00193
00194 $SQL2 = "SELECT sum(firstpost_value) AS anz FROM forum_post WHERE threadid = '$thread[threadid]' AND userID = ". $_SESSION['userid'];
00195 $res2 = $db->get_row($SQL2);
00196
00197
00198
00199
00200 $rating_value = $res2->anz;
00201
00202 if($res->userID != $_SESSION['userid'])
00203 {
00204
00205 for($i=0; $i<5; $i++) $checked[$i] = "";
00206
00207
00208 if(isset($_POST['Eval'][0]))
00209 {
00210 $checked_value= $_POST['Eval'][0];
00211
00212 $checked[5-$checked_value] = "checked='checked'";
00213
00214 }
00215 else
00216 $checked_value= 0;
00217
00218
00219
00220
00221
00222
00223 if (($res->threadrate) == 1 && $rating_value == 0)
00224 {
00225 $rating ="<tr class='tableCell'>
00226 <td>Bewertung</td>
00227 <td>
00228 <label for='preview'>Qualität des Themas</label><br/>
00229 <p class='pForm'>
00230 <input type='radio' name='Eval[]' ". $checked[0] ." value='5'> sehr gut
00231 <input type='radio' name='Eval[]' ". $checked[1] ." value='4'> gut
00232 <input type='radio' name='Eval[]' ". $checked[2] ." value='3'> mittel
00233 <input type='radio' name='Eval[]' ". $checked[3] ." value='2'> wenig brauchbar
00234 <input type='radio' name='Eval[]' ". $checked[4] ." value='1'> unbrauchbar
00235 </p>
00236 </td>
00237 </tr>";
00238 }
00239 elseif (($res->threadrate) == 0 && $rating_value == 0)
00240 {
00241 $rating="<tr class='tableCell'>
00242 <td>Bewertung</td>
00243 <td>Der Autor lässt keine Bewertung des Eintrags zu!</td>
00244 </tr>";
00245 }
00246 else
00247 {
00248 switch($rating_value){
00249 case 1: $value_str="unbrauchbar"; break;
00250 case 2: $value_str="wenig brauchbar"; break;
00251 case 3: $value_str="mittel"; break;
00252 case 4: $value_str="gut"; break;
00253 case 5: $value_str="sehr gut"; break;
00254 default: $value_str=""; break;
00255
00256 }
00257
00258
00259 $rating="<tr class='tableCell'>
00260 <td>Bewertung</td>
00261 <td>Sie haben bereits mit "" . $value_str ."" abgestimmt!</td>
00262 </tr>";
00263 }
00264 }
00265
00266 else $rating="";
00267
00268
00269
00270
00271 $courseID = $_SESSION['course'];
00272 $r_filesAllowed = forum_query("SELECT filesallowed FROM forum_board as board WHERE boardid = $board[boardid] AND is_photogallery=1");
00273 $filesAllowed = mysql_fetch_array($r_filesAllowed);
00274 if ($filesAllowed['filesallowed'])
00275 {
00276 $maxFileSize = upload::getMaxFileSize();
00277 if ($maxFileSize > 1024) {
00278 $showMaxFileSize = round($maxFileSize/1024, 2) ." MB";
00279 } else $showMaxFileSize = $maxFileSize." KB";
00280 $post['fileuploadrow'] = "<tr class='tableCell'> <td>Datei</td> <td> <p class='pForm'><input type='hidden' name='MAX_FILE_SIZE' value='".($settings["forum_max_filesize"]*1024) ."'/><input class='tbinput' type='file'
00281 name='userfile' size='20' /></p> maximal $showMaxFileSize</td></tr>";
00282 } else
00283
00284 {
00285 $post['fileuploadrow'] = "";
00286 }
00287
00288 eval($Tpostings->GetTemplate("RFORM"));
00289 eval($Tpostingrow->GetTemplate("CONTENT"));
00290 eval($Tframe->GetTemplate());
00291 include_once "footer.inc.php";
00293 require_once (PATH_TO_ROOT."common/footer.inc.php");
00294 exit;
00295 }
00296
00297 if ($_FILES['userfile']['name'] && $_FILES['userfile']['size'] == 0) {
00298 $msg.= "Fehler beim Upload der Datei... (@ Admin - php.ini überprüfen?!)";
00299 }
00300 if (($_FILES['userfile']['size']) != 0) {
00301
00302
00303
00304
00305
00306 $filesize = $_FILES['userfile']['size'];
00307 if (!(upload::fileSizeOK($filesize))) {
00308 $msg.= "Die Datei ist zu groß!<br/>";
00309 }
00310
00311
00312
00313
00314 if (!(upload::fileExtOK($_FILES['userfile']['name'], 1))) {
00315 $msg.= "Die Datei hat ein unerlaubtes Dateiformat.";
00316 }
00317
00318
00319 }
00320
00321 if ($thread['threadclosed'] == 1) {
00322 $msg = "Dieser Thread ist leider geschlossen, es können keine weiteren Antworten erstellt werden.";
00323 }
00324 if (isset($msg) && strlen($msg) > 0) {
00325 $navpath.= "Neue Antwort";
00326 errormessage("Fehler", "Es sind leider folgende Fehler aufgetreten:<br/><br/>$msg");
00327 }
00328 $ctime = time();
00329 if ($g_user['userID'] == 0 && $P->has_permission(P_REPLY)) {
00330 $g_user['username'] = $config['guestprefix'].$post['postguestname'];
00331 $post['postguestname'] = $config['guestprefix'].addslashes($post['postguestname']);
00332 } else {
00333 $post['postguestname'] = '';
00334 }
00335 if ($config["usebwordprot"] >= BWORD_POST) {
00336 $post["posttext"] = check_banned($post["posttext"]);
00337 }
00338 if (isset($config['auto_close']) && $config['auto_close'] > 0) {
00339 forum_query("UPDATE forum_thread SET threadclosed = '1' WHERE threadtime < '".(time() -(($config['auto_close']+1) *86400)) ."'");
00340 }
00341 if (isset($config['auto_delete']) && $config['auto_delete'] > 0) {
00342 forum_query("DELETE FROM forum_thread WHERE threadtime < ".(time() -($config['auto_delete']*86400)) ."");
00343 }
00344
00345
00346
00347
00348 if (($_FILES['userfile']['size']) != 0) {
00349 $post['postfilename'] = $_FILES['userfile']['name'];
00350 $post['postfilesavename'] = $_SESSION['userid'].time() .$_SESSION['course'];
00351 $post['postfilesize'] = $_FILES['userfile']['size'];
00352 $courseID = $_SESSION['course'];
00353 $boardID = $board['boardid'];
00354
00355
00356 $uploaddir = PATH_TO_ROOT.$settings["upload_path"]."forum/course/".$courseID."/board/".$boardID;
00357 Utilities::mkdir_r($uploaddir);
00358
00359 if (!(@move_uploaded_file($_FILES['userfile']['tmp_name'], $uploaddir."/".$post['postfilesavename']))) {
00360 $msg.= "Fehler beim Speichern der Datei!<br/>";
00361 }
00362 }
00363
00364
00365
00366
00367
00368 if(isset($_POST['Eval'][0]))
00369 {
00370 $checked_value= $_POST['Eval'][0];
00371 }
00372 else
00373 $checked_value=0;
00374
00375
00376
00377 forum_query("INSERT INTO forum_post (posttime, posttext, userID, threadid, postsmilies, postcode, postguestname, postfilename, postfilesavename, postfilesize, firstpost_value)
00378 VALUES('$ctime',
00379 '".Data::toMysql($post['posttext'], false) ."',
00380 '".intval($g_user['userID']) ."',
00381 '".intval($thread['threadid']) ."',
00382 '".($post['postsmilies'] ? 1 : 0) ."',
00383 '".($post['postcode'] ? 1 : 0) ."',
00384
00385 '".(isset($post['postguestname']) ? Data::toMysql($post['postguestname'], false) : '') ."',
00386 '".(isset($post['postfilename']) ? Data::toMysql($post['postfilename'], false) : '') ."',
00387 '".(isset($post['postfilesavename']) ? Data::toMysql($post['postfilesavename'], false) : '') ."',
00388 '".(isset($post['postfilesize']) ? intval($post['postfilesize']) : 0) ."'," .
00389 Data::toMysql($checked_value) .")");
00390 $post["postid"] = mysql_insert_id();
00391
00392
00393 $lastPostBy = $g_user['username'];
00394 if (isset($role)) {
00395 RoleArtefacts::setRoleForItem(FORUM, $post["postid"], $_SESSION["roleID"]);
00396 $lastPostBy.= " (".$role->getName($_SESSION["gender"]) .")";
00397 }
00398 if (isset($team)) {
00399 TeamArtefacts::setTeamForItem(FORUM, $post["postid"], $_SESSION["teamID"]);
00400 $lastPostBy.= " (".$team->getName() .")";
00401 }
00402
00403 forum_query("UPDATE forum_board SET
00404 boardlastpost='$ctime',
00405 boardposts=boardposts+1,
00406 boardlastpostby='".Data::toMysql($lastPostBy, false) ."',
00407 boardthreadtopic='".Data::toMysql($thread['threadtopic'], false) ."',
00408 boardthreadid='$thread[threadid]' WHERE boardid='$board[boardid]' AND is_photogallery=1");
00409 if ($g_user['userID']) {
00410
00411 forum_query("UPDATE forum_user SET userlastpost=$ctime, userposts=userposts+1 WHERE userID='$g_user[userID]'");
00412 }
00413
00414 $lastReplyBy = $g_user['username'];
00415 if (isset($role)) {
00416 $lastReplyBy.= " (".$role->getName($_SESSION["gender"]) .")";
00417 }
00418 if (isset($team)) {
00419 $lastReplyBy.= " (".$team->getName() .")";
00420 }
00421 forum_query("UPDATE forum_thread SET threadtime='$ctime', threadreplies=threadreplies+1,
00422 threadlastreplyby='".Data::toMysql($lastReplyBy, false) ."' WHERE threadid='$thread[threadid]'");
00423
00424 $arrBoardInfo = mysql_fetch_array(forum_query("SELECT mustsee FROM forum_board as board WHERE boardid = $board[boardid] AND is_photogallery=1"));
00425 if ($arrBoardInfo['mustsee'] == 0)
00426 $objDistributionHandler = new SubscribersDistributionHandler(false, $board, $thread, $g_user, $post, $config, $course_name, $settings, $mainBBCode, $db);
00427 else
00428 $objDistributionHandler = new MustseeDistributionHandler(false, $board, $thread, $g_user, $post, $config, $course_name, $settings, $mainBBCode, $db);
00429 $objDistributor = new Distributor();
00430 $objDistributor->setDistributionHandler($objDistributionHandler);
00431 $objDistributor->distribute();
00432
00433
00434 if (isset($_POST['picquote']) && $post['postid']) {
00435 $db->query("INSERT INTO photogallery_picquote VALUES ('', ".intval($thread['threadid']) .", ".$post['postid'].", ".$_POST['cx1'].", ".$_POST['cy1'].", ".$_POST['cx2'].", ".$_POST['cy2'].") ");
00436 }
00437 message_redirect("Eintrag erfolgreich", "showtopic.php?threadid=$thread[threadid]&time=$ctime&pagenum=lastpage");
00438 include_once "footer.inc.php";
00440 require_once (PATH_TO_ROOT."common/footer.inc.php");
00441 ?>